// 当前日期对象
export function today() {
  return new Date();
}
// 当前年份 yyyy
export const year = today().getFullYear();
// 当前月份 mm
export const month = String(today().getMonth() + 1).padStart(2, "0");
// 当前日期 dd
export const day = String(today().getDate()).padStart(2, "0");
// 当前年份字符串
export const yearDate = `${year}`;
// 当前年月字符串（年-月）
export const formattedDate = `${year}-${month}`;
// 当前日期字符串（年-月-日）
export const dayDate = `${year}-${month}-${day}`;
// 获取前一天的日期对象
export function getPreviousDay() {
  const today = new Date();
  const previousDay = new Date(today);
  previousDay.setDate(today.getDate() - 1);
  return previousDay;
}
// 前一天的年份
export const previousYear = getPreviousDay().getFullYear();
// 前一天的月份
export const previousMonth = String(getPreviousDay().getMonth() + 1).padStart(2,"0");
// 前一天的日
export const previousDay = String(getPreviousDay().getDate()).padStart(2, "0");
// 前一天的（年-月-日）
export const lastDayDate = `${previousYear}-${previousMonth}-${previousDay}`;
// 当前小时
export const hour = today().getHours();
// 时分秒
export const hours = today().getHours().toString().padStart(2, "0");
export const minutes = today().getMinutes().toString().padStart(2, "0");
export const seconds = today().getSeconds().toString().padStart(2, "0");
export const hms = `${hours}:${minutes}:${seconds}`;
//   年月日时分秒
export const ymdhms = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
